package com.wuhenzhizao.sku.view;

import com.wuhenzhizao.sku.ResourceTable;
import com.wuhenzhizao.sku.utils.ScreenUtils;
import ohos.agp.components.AttrSet;
import ohos.agp.components.Text;
import ohos.agp.components.element.ShapeElement;
import ohos.agp.utils.TextAlignment;
import ohos.app.Context;

/**
 * Sku项目组件
 *
 * @author wuhenzhizao
 * @since 2017-08-02
 */
public class SkuItemView extends Text {
    private String attributeValue;

    /**
     * 构造
     *
     * @param context
     */
    public SkuItemView(Context context) {
        this(context,null);
    }

    /**
     * 构造
     *
     * @param context
     * @param attrSet
     */
    public SkuItemView(Context context, AttrSet attrSet) {
        this(context, attrSet,null);
    }

    /**
     * 构造
     *
     * @param context
     * @param attrSet
     * @param styleName
     */
    public SkuItemView(Context context, AttrSet attrSet, String styleName) {
        super(context, attrSet, styleName);
        init(context);
    }


    private void init(Context context) {
        ShapeElement shapeElement = new ShapeElement(context, ResourceTable.Graphic_sku_item1);
        shapeElement.setShape(ShapeElement.RECTANGLE);
        setBackground(shapeElement);
        setTextSize(11,TextSizeType.FP);
        setMultipleLine(false);

        setTextAlignment(TextAlignment.CENTER);
        setPadding(ScreenUtils.dp2PxInt(context, 10), 0, ScreenUtils.dp2PxInt(context, 10), 0);

        setMinWidth(ScreenUtils.dp2PxInt(context, 45));

        setMaxTextWidth(ScreenUtils.dp2PxInt(context, 200));
    }

    public String getAttributeValue() {
        return attributeValue;
    }

    public void setAttributeValue(String attributeValue) {
        this.attributeValue = attributeValue;
        setText(attributeValue);
    }


}
